On LR(k)-Parsers of Polynomial Size
نویسنده
چکیده
Usually, a parser for an LR(k)-grammar G is a deterministic pushdown transducer which produces backwards the unique rightmost derivation for a given input string x ∈ L(G). The best known upper bound for the size of such a parser is O(2|G||Σ| +k log |Σ|+log |G|) where |G| and |Σ| are the sizes of the grammar G and the terminal alphabet Σ, respectively. If we add to a parser the possibility to manipulate a directed graph of size O(|G|n) where n is the length of the input then we obtain an extended parser. The graph is used for an efficient parallel simulation of all potential leftmost derivations of the current right sentential form such that the unique rightmost derivation of the input can be computed. Given an arbitrary LR(k)-grammar G, we show how to construct an extended parser of O(|G|+ #LA|N |2kk log k) size where |N | is the number of nonterminal symbols and #LA is the number of relevant lookaheads with respect to the grammar G. As the usual parser, this extended parser uses only tables as data structure. Using some ingenious data structures and increasing the parsing time by a small constant factor, the size of the extended parser can be reduced to O(|G| + #LA|N |k2). The parsing time is O(ld(input) +k|G|n) where ld(input) is the length of the derivation of the input. Moreover, we have constructed a one pass parser.
منابع مشابه
Eine Rekonstruktion der LR-Theorie zur Elimination von Redundanz mit Anwendung auf den Bau von ELR-Parsern
In this thesis, we present work on two problems from the field of LR parser construction, a family of syntax analysis techniques for context-free languages. In the first part, we show that the traditional LR parser construction technique produces parsers which are burdened with a substantial amount of systematic redundance. We develop a new and well-founded method which defines what we call gen...
متن کاملOn the size of parsers and LR(k)-grammars
In this paper, we consider two tradeo results regarding the economy of description in parsing. One result is on the tradeo between the size of a parser and its ability to detect an error early. The other result is on the tradeo between the size of an LR(k)-grammar and the length k of the lookahead. c © 2000 Elsevier Science B.V. All rights reserved.
متن کاملSimple LR ( k ) Grammars Franklin
A class of context-free grammars, called the "Simple LR(k)" or SLR(k) grammars is defined. This class has been shown to include weak precedence and simple precedence grammars as proper subsets. How to construct parsers for the SLR(k) grammars is also shown. These parser-construction techniques are extendible to cover all of the LR(k) grammars of Knuth; they have been implemented and by direct c...
متن کاملPolynomial Time and Space Shift-Reduce Parsing of Arbitrary Context-free Grammars
We introduce an algorithm for designing a predictive left to right shift-reduce non-deterministic push-down machine corresponding to an arbitrary unrestricted context-free grammar and an algorithm for efficiently driving this machine in pseudo-parallel. The performance of the resulting parser is formally proven to be superior to Earley's parser (1970). The technique employed consists in constru...
متن کاملLLLR Parsing: a Combination of LL and LR Parsing
A new parsing method called LLLR parsing is defined and a method for producing LLLR parsers is described. An LLLR parser uses an LL parser as its backbone and parses as much of its input string using LL parsing as possible. To resolve LL conflicts it triggers small embedded LR parsers. An embedded LR parser starts parsing the remaining input and once the LL conflict is resolved, the LR parser p...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 2010